<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="../image/png">
  <title>Demo</title>
  <!--data table-->
  <link rel="stylesheet" href="../js/data-tables/DT_bootstrap.css" />


</head>
<body class="sticky-header" onload="indexmenu('${oneMenu}','${twoMenu}');">
<%@ include file="../index/index.jsp" %>
<section>
	<div class="main-content">
        <!-- 地址栏-->
		<div class="page-heading">
            <h3>
                	后台管理系统
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">APP管理</a>
                </li>
                <li class="active">APP启动广告</li>
            </ul>
        </div>   
		<!--这里是写一些内容的  -->
		<!--这里是写一些内容的  -->
		<div class="row">
	        <div class="col-sm-12">
	        	<section class="panel">
		        	<div class="panel-body">
		        		<div class="adv-table">
		      				<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline" role="grid">
		        				<div class="span6">
		        					<h4>app启动广告列表:</h4>
		       		 			</div>
		       				</div>
		       				<!--表格开始  -->
			       			<table class="display table table-bordered table-striped dataTable table-hover" id="dynamic-table" aria-describedby="dynamic-table_info">
			        			<thead>
						        	<tr role="row">
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 80px;" aria-label="Rendering engine: activate to sort column ascending">广告id</th>
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 80px;" aria-label="Rendering engine: activate to sort column ascending">广告图片</th>						        	
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">广告名称</th>						        							        		
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">广告状态</th>
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">app名字</th>
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">编辑</th>
						        	</tr>
						        </thead>
							    <tbody role="alert" aria-live="polite" aria-relevant="all">
							    	<c:forEach var="advertise" items="${advertises}">
							        	<tr class="gradeA even">
							           		<td class="">${advertise.adverId}</td>
							           		<td class=""  data-toggle="modal" data-target="#adverPictureModel" onclick="adverPictureTd(${advertise.adverId})">
							           			<img src="http://oeilufnx2.bkt.clouddn.com/${advertise.img}?imageView2/1/w/100/h/100">
							           		</td>			           				
								            <td class="" data-toggle="modal" data-target="#adverDetailDiv">${advertise.adverName}</td>			           												            
								            <c:if test="${advertise.adverStatus==0}">
								           		<td class="">关闭</td>
								            </c:if>
								            <c:if test="${advertise.adverStatus==1}">
								           		<td class="">启动</td>
								            </c:if>								            
								            <td class="">${advertise.appName}</td>			           												            							            								            
								          	<td class="">
									            <c:if test="${advertise.adverStatus==0}">
									           		<button class="btn btn-info" type="button" onclick="updateAdverSwitch(${advertise.adverId},${advertise.adverStatus})">开启</button>
									          		<button class="btn btn-info" type="button" data-toggle="modal" data-target="#addNewPicture" onclick="toUpdateAdverPircture(${advertise.adverId})">修改图片</button>
									            </c:if>
								           		<c:if test="${advertise.adverStatus==1}">
									           		<button class="btn btn-info" type="button" onclick="updateAdverSwitch(${advertise.adverId},${advertise.adverStatus})">关闭</button>
									          		<button class="btn btn-info" type="button" data-toggle="modal" data-target="#addNewPicture" onclick="toUpdateAdverPircture(${advertise.adverId})">修改图片</button>	
									            </c:if>					     
								         	</td>
								         							            
								        </tr>							    		
							    	</c:forEach>
							  	</tbody>
							</table>
							<!-- 表格结束 -->
							<!-- 分页开始 -->
						  	<div class="row-fluid">
							  	<div class="span6">
								  	<div class="dataTables_paginate paging_bootstrap pagination">
									  	<ul>									  		
								  			<c:choose>
									  			<c:when test="${page.currentPage==1}">
									  				<li class="prev">
									  					<a class="page-link">← 上一页</a>
									  				</li>
									  			</c:when>
									  			<c:otherwise>
									  				<li class="prev">
									  					<a href="../app/appAd.do?currentPage=${page.currentPage-1}" class="page-link">← 上一页</a>
									  				</li>
									  			</c:otherwise>	 							  			
								  			</c:choose>
						                  <c:forEach begin="1" end="${page.totalPage}" var="p">
						                    	<c:choose>
						                    		<c:when test="${page.currentPage==p}">
						                    			<c:if test="${p==1}">
						                    				<li  class="active page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p}" class="page-link">${p}</a></li> 
						                    				<c:if test="${page.totalPage>1}">
						                    					<li  class="page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p+1}">${p+1}</a></li>
						                    				</c:if>
						                    				<c:if test="${page.totalPage>2}">
						                    					<li  class="page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p+2}">${p+2}</a></li>
						                    				</c:if>
						                    				<c:if test="${page.totalPage>3}">
							                    				<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    			</c:if>
						                    			</c:if>
						                    			<c:if test="${p>1}">                   			                   			
							                    			<c:if test="${p<page.totalPage}">
							                    				<c:if test="${p>2}">
							                    					<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    				</c:if>
							                    				<li class="page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p-1}">${p-1}</a></li>
							                    				<li class="active page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p}" class="current_page">${p}</a></li>
							                    				<c:if test="${page.totalPage>2}">
							                    					<li class="page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p+1}">${p+1}</a></li>
							                    				</c:if>
							                    				<c:if test="${page.totalPage-p>1}">
							                    					<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    				</c:if>
							                    			</c:if>
							                    			<c:if test="${p==page.totalPage}">
							                    				<c:if test="${p>3}">
							                    					<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    				</c:if>
							                    				<c:if test="${p>2}">
							                    					<li class="page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p-2}">${p-2}</a></li>
							                    				</c:if>
							                    				<li class="page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p-1}">${p-1}</a></li>
							                    				<li class="active page-item"><a class="page-link" href="../app/appAd.do?currentPage=${p}" class="current_page">${p}</a></li>
							                    			</c:if>
						                    			</c:if>
						                    		</c:when>
						                    	</c:choose>
						                    </c:forEach>					

								  			<c:choose>
									  			<c:when test="${page.currentPage==page.totalPage}">
									  					<li class="pre"><a class="page-link">下一页 → </a></li>
									  			</c:when>
									  			<c:otherwise>
									  					<li class="pre"><a href="../app/appAd.do?currentPage=${page.currentPage+1}" class="page-link">← 下一页</a>
									  					</li>
									  			</c:otherwise>	 							  			
								  			</c:choose>
											<li class="page-item"> <a class="page-link">总共${page.totalPage}页</a></li>
									  	</ul>
								  	</div>
								</div>
							</div>
							<!-- 分页结束 -->
						</div>
					</div>
        		</section>
        	</div>
       </div>				
		<!-- 内容结束 -->
	</div>
</section>
      <!-- 广告图片模态框 -->
		<div class="modal fade" id="adverPictureModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  <div class="modal-dialog">
		    <div class="modal-content" style="width: 841px;">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		        <h4 class="modal-title" id="myModalLabel">该广告图片</h4>
		      </div>
		      <div class="modal-body">
		       <!--这是模态框内容  -->
		       <!-- 这是模态框内容结束 -->
		      </div>
		      <div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		      </div>
		    </div>
		  </div>
		</div> 
       
		<!-- 模态框结束 -->
      <!--换广告图片模态框 -->
		<div class="modal fade" id="addNewPicture" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  <div class="modal-dialog">
		    <div class="modal-content" style="width: 841px;">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		        <h4 class="modal-title" id="myModalLabel">换广告图片</h4>
		      </div>
		      <div class="modal-body">
		       <!--这是模态框内容  -->
			  		<form id="inputForm" action="../app/testUpload.do" method="post" enctype="multipart/form-data"> 
	                   <input type="hidden" id="adverIdInput" name="adverId">
	                   <input type="hidden" id="returnDataInput" value="${returnData}">
	                   <div class="col-md-9">
	                       <div class="fileupload fileupload-new" data-provides="fileupload">
	
	                           <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
	                           <div>
	                                 	 选择文件:<input type="file" name="file"> 
	                           </div>
	                       </div>
	                       <br>
	                      <!--  <input type="submit" value="提交">  -->
	                   </div>	                  	           
					</form> 								       
		       <!-- 这是模态框内容结束 -->
		      </div>
 		      <div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="submit" class="btn btn-default" data-dismiss="modal" onclick="saveNewAdPicture()">保存</button>
		      </div>	 	      
		    </div>
		  </div>
		</div> 
       
		<!-- 模态框结束 -->



</body>
<script type="text/javascript" src="../js/app/app.js"></script>
<script type="text/javascript" src="../js/bootstrap-fileupload.min.js"></script>
<script type="text/javascript">


</script>
</html>
